using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using HCD.Const;
using HCD.Entities;
using HCD.Mdt.Dtos;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;

namespace HCD.Mdt
{
    [Route("api/[controller]/[action]"), ApiController]
    public class MdtCommentAppService : AsyncCrudAppService<MdtComment, MdtCommentDto, long, MdtCommentGetAllInput, MdtCommentEditInput, MdtCommentEditInput, EntityDto<long>, EntityDto<long>>, IMdtCommentAppService
    {
        public MdtCommentAppService(IRepository<MdtComment, long> repository)
        : base(repository)
        {
            LocalizationSourceName = EnterpriseConsts.LocalizationSourceName;
        }
        /// <summary>
        /// 新增Mdt会诊意见
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost,ActionName("Add")]
        public override async Task<MdtCommentDto> CreateAsync(MdtCommentEditInput input)
        {
            return await base.CreateAsync(input);
        }
        /// <summary>
        /// 编辑Mdt会诊意见
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut, ActionName("Edit")]
        public override async Task<MdtCommentDto> UpdateAsync(MdtCommentEditInput input)
        {
            return await base.UpdateAsync(input);
        }
        /// <summary>
        /// 删除Mdt会诊意见
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpDelete, ActionName("Delete")]
        public override async Task DeleteAsync(EntityDto<long> input)
        {
            await base.DeleteAsync(input);
        }
        /// <summary>
        /// 获取单个Mdt会诊意见
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet, ActionName("Get")]
        public override async Task<MdtCommentDto> GetAsync([FromQuery]EntityDto<long> input)
        {
            return await base.GetAsync(input);
        }
        /// <summary>
        /// 分页获取Mdt会诊意见
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet, ActionName("GetList")]
        public override async Task<PagedResultDto<MdtCommentDto>> GetAllAsync([FromQuery]MdtCommentGetAllInput input)
        {
            return await base.GetAllAsync(input);
        }
        protected override IQueryable<MdtComment> CreateFilteredQuery(MdtCommentGetAllInput input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(string.IsNullOrWhiteSpace(input.Query), t => t.Comment == input.Query);
        }
    }
}


